//
//  EHSeperatorLineRow.swift
//  ExtremeHealth
//
//  Created by Zhongkai Li 李忠凯 on 2018/8/27.
//  Copyright © 2018 GanDongKeJi. All rights reserved.
//

import Eureka

class EHSeperatorLineCell: Cell<Bool>, CellType {
    var line: UIView!

    override func setup() {
        super.setup()
        setupLine()
        height = { 2 }
    }

    private func setupLine() {
        let line = UIView()
        line.backgroundColor = .red
        line.translatesAutoresizingMaskIntoConstraints = false
        contentView.addSubview(line)
        NSLayoutConstraint.activate([
            line.leftAnchor.constraint(equalTo: contentView.leftAnchor,
                                       constant: (row as? EHSeperatorLineRow)?.leftMargin ?? 0),
            line.rightAnchor.constraint(equalTo: contentView.rightAnchor,
                                        constant: (row as? EHSeperatorLineRow)?.rightMargin ?? 0),
            line.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
            line.heightAnchor.constraint(equalToConstant: 1 / UIScreen.main.scale)
            ])

        self.line = line
    }
}

final class EHSeperatorLineRow: Row<EHSeperatorLineCell>, RowType {
    var leftMargin: CGFloat = 0
    var rightMargin: CGFloat = 0
}
